package game.services;

import dou.net.protocol.ProtocolManager;
import dou.net.socket.InvalidProtocolException;
import game.services.chat.ChatProtocol;
import game.services.session.SessionProtocol;

/**
 * 程序使用到的所有协议管理类
 * @author wizardc
 */
public class ServicesProtocolManager
{
    private static SessionProtocol _sessionProtocol;
    private static ChatProtocol _chatProtocol;

    /**
     * 初始化所有协议对象
     */
    public static void initializeProtocols() throws InvalidProtocolException
    {
        _sessionProtocol = new SessionProtocol(2, 4, 60L, Thread.NORM_PRIORITY);
        ProtocolManager.getInstance().registerProtocol(_sessionProtocol);
        _chatProtocol = new ChatProtocol(2, 4, 60L, Thread.NORM_PRIORITY);
        ProtocolManager.getInstance().registerProtocol(_chatProtocol);
    }

    /**
     * 清除所有协议对象
     */
    public static void cleanupProtocols()
    {
        _sessionProtocol.cleanup();
        _chatProtocol.cleanup();
    }
}
